<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model backend\modules\home\models\MhConfig */

$this->title = '详情：' . $model->title;
$this->params['breadcrumbs'][] = ['label' => '配置列表', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="mh-config-view">
    <p>
        <?= Html::a('更新', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
        <?= Html::a('删除', ['delete', 'id' => $model->id], [
            'class' => 'btn btn-danger',
            'data' => [
                'confirm' => 'Are you sure you want to delete this item?',
                'method' => 'post',
            ],
        ]) ?>

        <?php if($model->type == 'img'){ ?>
            <?= Html::a('图片上传', ['upload', 'id' => $model->id], ['class' => 'btn btn-info']) ?>
        <?php }?>
    </p>

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            [
                'format' => 'raw',
                'attribute' => 'cid',
                'value' => function($model) {
                    if($model->cid == 1){
                        return '基本设置';
                    }elseif($model->cid == 2){
                        return '联系我们';
                    }else{
                        return '';
                    }
                },
            ],
            [
                'format' => 'raw',
                'attribute' => 'type',
                'value' => function($model) {
                    if($model->type == 'img'){
                        return '图片';
                    }else{
                        return '文本';
                    }
                },
            ],
            'key',
            'title',
            [
                'format' => 'raw',
                'attribute' => 'value',
                'value' => function($model) {
                    if($model->type == 'img'){
                        return '<img src="'.$model->value.'" style="height:100px">';
                    }else{
                        return $model->value;
                    }
                },
            ],
            'remark',
            'sort',
            [
                'format' => 'raw',
                'attribute' => 'create_time',
                'value' => function($model) {
                    return date('Y-m-d H:i', $model->create_time);
                },
            ],
        ],
    ]) ?>

</div>
